/**
 *
 */
$(function(){



});

function soapWrapFunc(bdStr){
    // 封装SOAP头尾
    var soapHead = '<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://Webservice.zjusc.edu.cn/"><env:Body>', soapTail = '</env:Body></env:Envelope>';
    return soapHead + bdStr + soapTail;
}

//加载日志数据
function LogData(typID){
    var getLogStrBody = '<web:GetLogInfoByType><typeID>' + typID + '</typeID></web:GetLogInfoByType>';
    
    $.ajax({
        type: "POST",
        contentType: "text/xml",
        url: '../../Service/LogService',
        data: soapWrapFunc(getLogStrBody),
        dataType: 'xml',
        success: function(xml){
            var logTableHtml = '<tbody>';
            var dateReg = /\d{4}\-\d{2}\-\d{2}/, timeReg = /[0-2]{1}[0-6]{1}\:[0-5]{1}[0-9]{1}\:[0-5]{1}[0-9]{1}/;
            $.each($(xml).find('item'), function(i, n){
                logTableHtml += (i % 2 == 0) ? '<tr>' : '<tr class="odd">';
                logTableHtml += '<td>' + (i + 1) + '<input type="hidden" value="' + $(this).find('id').text() + '" /></td>';
                logTableHtml += '<td>' + $(this).find('type').text() + '</td>';
                var dtVal = $(this).find('recordTime').text();
				logTableHtml += '<td>' +dtVal.match(dateReg) +'  ' +dtVal.match(timeReg) +'</td>';
                logTableHtml += '<td>' + $(this).find('event').text() + '</td>';
                logTableHtml += '</tr>';
            });
            logTableHtml += '</tbody>';
            $('#logInfoTable').append(logTableHtml);
        },
        beforeSend: function(xhr){
            xhr.setRequestHeader("SOAPAction", "\"\"");
        },
        error: function(x, e){
            alert('error:' + x.responseText);
        },
        complete: function(x){
        
        }
    });
}

$(window).load(function(){
    LogData($.logType);
});
/*
 *
 *
 */
